<?php
class Email extends Doctrine_Record {
    public function setTableDefinition() {
        $this->setTableName('email');
        $this->hasColumn('id', 'integer', 5, array('primary' => true, 'unsigned'=>true, 'autoincrement'=>true));
        $this->hasColumn('value', 'string', 255);
        $this->hasColumn('nombre', 'string', 255);
        $this->hasColumn('facebook', 'string', 50);
        $this->hasColumn('estado', 'integer', 1, array('unsigned'=>true, 'default'=>0));
    }
    
    public static function total() {
        return Doctrine_Query::create()
                ->select('count(DISTINCT value)')
                ->from('Email')
                ->where('value IS NOT NULL and value <> ?', '')
                ->execute(array(), Doctrine::HYDRATE_SINGLE_SCALAR);
    }
    
    public static function pendientes() {
        return Doctrine_Query::create()
                ->select('count(DISTINCT value)')
                ->from('Email')
                ->where('value IS NOT NULL and value <> ?', '')
                ->andWhere('estado = 0')
                ->execute(array(), Doctrine::HYDRATE_SINGLE_SCALAR);
    }
}
?>